using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Pacocofose
{

    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;


        Itens item;
        Terreno terreno;
        Personagem personagem;
        Instrucoes instrucao;
        Poder poder;


        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }


        protected override void Initialize()
        {


            graphics.PreferredBackBufferWidth = 800; // Largura
            graphics.PreferredBackBufferHeight = 600; // Altura
            graphics.IsFullScreen = false;            
            graphics.ApplyChanges();

            base.Initialize();

        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            item = new Itens(Content.Load<Texture2D>("Item"));
            terreno = new Terreno(this);
            personagem = new Personagem(this);
            instrucao = new Instrucoes(this);
            poder = new Poder(this);
        }


        protected override void UnloadContent()
        {

        }


        protected override void Update(GameTime gameTime)
        {

            item.Update();
            terreno.Update();
            personagem.Update(gameTime);
            instrucao.Update(this, gameTime);
            poder.Update(gameTime);

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();


            KeyboardState keyboardstate = Keyboard.GetState();



            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {

            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            
            terreno.Draw(spriteBatch);
            item.Draw(spriteBatch);
            personagem.Draw(spriteBatch);
            instrucao.Draw(spriteBatch);
            poder.Draw(spriteBatch);


            spriteBatch.End();


            base.Draw(gameTime);
        }

    }

}
